import { fliterPermission } from '@/utils/sys.js'
export const apis = {
  list: `/business/transfer/getList?modelCode=MODEL_TRANSFER&authCode=FUNCTION_TRANSFER_LIST`,
  detail: `business/transfer/detail?modelCode=MODEL_TRANSFER&authCode=BTN_TRANSFER_DETAIL`,
  audit: `business/transfer/audit?modelCode=MODEL_TRANSFER&authCode=BTN_TRANSFER_AUDIT`,
  getWaitOutboundDeatil: `business/transfer/getWaitOutboundDeatil?modelCode=MODEL_TRANSFER&authCode=BTN_TRANSFER_OUTBOUND`,
  outbound: `business/transfer/outbound?modelCode=MODEL_TRANSFER&authCode=BTN_TRANSFER_OUTBOUND`,
  getOutboundDeatil:`business/transfer/getOutboundDeatil?modelCode=MODEL_TRANSFER&authCode=BTN_TRANSFER_CONTAINER`,
  cabinet: `business/transfer/cabinet?modelCode=MODEL_TRANSFER&authCode=BTN_TRANSFER_CONTAINER`,
  verify: `business/transfer/verify?modelCode=MODEL_TRANSFER&authCode=BTN_TRANSFER_VERIFY`,
  pass: `business/transfer/pass?modelCode=MODEL_TRANSFER&authCode=BTN_TRANSFER_PASS`,
  arrive: `business/transfer/arrvied?modelCode=MODEL_TRANSFER&authCode=BTN_TRANSFER_ARRIVE`,
  getTransitDeatil: `business/transfer/getTransitDeatil?modelCode=MODEL_TRANSFER&authCode=BTN_TRANSFER_ARRIVE`,
  deliver: `business/transfer/delivery?modelCode=MODEL_TRANSFER&authCode=BTN_TRANSFER_DELIVER`,
  getUserList: `/business/user/getUserList?authCode=FUNCTION_ORDER_LIST`,
};

export const configs = {
  listUrl: apis.list,
  pageOn: true, // 开启分页
  searchOn: true, // 开启搜索
  operateOn: true, //开启操作区域
  treeOn: false, // 开启树形
  searchMode:'custome',
};


export const searchs = [

  {
    type: "SelectModel",
    column: "user_id",
    label: "用户",
    url:apis.getUserList,
    mapping : {
      label:['user_nick'],
      value: 'id'
    },
    
  },
  {
    type: "SelectModel",
    column: "user_id",
    label: "用户编号",
    url:apis.getUserList,
    mapping : {
      label:['id'],
      value: 'id'
    },
 
  },
  {
    type: "SelectModel",
    column: "transfer_mode",
    label: "运输方式",
    modelCode: "MODEL_TRANSPORT_MODE",
    mapping : {
      label:['transport_mode_name'],
      value: 'id'
    }
  },
  {
    type: "SelectModel",
    column: "transfer_outbound_personnel",
    label: "出库员",
    modelCode: "MODEL_BUSINESS_MANAGE",
    mapping : {
      label:['manage_account'],
      value: 'id'
    }
  },
  {
    type: "Input",
    column: "transfer_no",
    label: "转运单号",
  },
  
  {
    type: "Input",
    column: "transfer_outbound_no",
    label: "出库单号",
  },


  {
    type: "DatePicker",
    column: "transfer_outbound_time",
    label: "出库时间",
  }
];

export const pages = {
  pageSize: 20,
  orders: [
    {
      field: "id",
      sort: "desc",
    },
  ],
  defaultSearchParam:[]
 
};
export const columns = [
  { type: "selection" },
  {
    label: "用户编号",
    column: "user_id",
  },

  {
    label: "用户昵称",
    column: "user_id",
    display: "detail",
    format:'model',
    config: {
      mode:'custom', //'default', 默认，custom自定义方式
      component: 'user/components/Mode',
    }
  },
  {
    label: "转运单号",
    column: "transfer_no",
    display: "detail",
  },
  {
    label: "运输方式",
    column: "transfer_mode",
    format:'model',
  },
  {
    label: "状态",
    column: "transfer_state",
    display: "state",
    format:'dim'
  },
  {
    label: "清关状态",
    column: "verify_state",
    display: "state",
    format:'dim'
  },
  {
    label: "支付状态",
    column: "pay_state",
    display: "state",
    format:'dim'
  },
  {
    label: "柜号",
    column: "transfer_cabinet_number",
  },
  {
    label: "派送方式",
    column: "delivery_type",
    display: "state",
    format:'dim'
  },
  {
    label: "派送备注",
    column: "delivery_remark",
  },
  {
    label: "派送时间",
    column: "delivery_time",
    format: "datetime",
    display: "text",
  },
  // {
  //   label: "出库员",
  //   column: "transfer_outbound_manage",
  //   display: "text",
  //   format:'model',
  //   config: {
  //     mode:'custom', //'default', 默认，custom自定义方式
  //     component: 'business/Mode',
  //   }
  // },
   {
    label: "出库单号",
    column: "transfer_outbound_no", 
  },
  {
    label: "出库时间",
    column: "transfer_outbound_time",
    format: "datetime",
    display: "text",
  },
  {
    label: "运输费用",
    column: "transfer_price",
  },
  {
    label: "运输成本",
    column: "transfer_cost",
  },
   {
    label: "利润",
    column: "transfer_cost",
    slot:'profit'
  },
  {
    label: "其他费用",
    column: "transfer_other",
  },
  {
    label: "代理提成",
    column: "transfer_agent_cost",
  },
  {
    label: "创建时间",
    column: "ctime",
    display: "text",
  },
  { label: "操作", column: "operate", width: "240", fixed: "right" },
];

export const buttons = fliterPermission([
  {
    operate: "outbound",
    text: "出库单录入",
    permission: 'BTN_TRANSFER_OUTBOUND',
    state: "2"
  },
  {
    operate: "container",
    text: "补充柜号",
    permission: 'BTN_TRANSFER_CONTAINER',
    state: "3"
  },
  {
    operate: "verify",
    text: "查验",
    permission: 'BTN_TRANSFER_VERIFY',
    state: "4"
  },
  {
    operate: "pass",
    text: "放行",
    permission: 'BTN_TRANSFER_PASS',
    state: "4"
  },
  {
    operate: "arrive",
    text: "到柜",
    permission: 'BTN_TRANSFER_ARRIVE',
    state: "4"
  },
   {
    operate: "deliver",
    text: "派送",
    permission: 'BTN_TRANSFER_DELIVER',
    state: "5"
  },

]);
export const columnButtons = fliterPermission([
  {
    operate: "detail",
    text: "详情",
    permission: 'BTN_TRANSFER_DETAIL',
  },
  {
    operate: "audit",
    text: "审核",
    permission: 'BTN_TRANSFER_AUDIT',
    hidden: ({ row })=> {
      if(['3'].includes(row.pay_state)){
        return false
      }
      return true
    },
  },
  // {
  //   operate: "outbound",
  //   text: "出库",
  //   permission: 'BTN_ORDER_OUT',
  // },
  // {
  //   operate: "edit",
  //   text: "编辑",
  //   permission: 'BTN_ORDER_EDIT',
  // }
 
]);
